#include("/template/common/layout/_page_layout.html")
#@layout()

#define css()
<style>
    h3 {
        font-weight: bold;
    }


</style>
#end

#define content()
<div class="x-body">
    <form id="impTeam" class="layui-form">
        <h2>项目简介</h2>
        <hr class="layui-bg-red">
        <div class="layui-form-item">
            <div class="layui-input-inline">
                <h3>项目名称:</h3>
                <div>
                    <span>#(project.name)</span>
                </div>
            </div>
            <div class="layui-input-inline">
                <h3>角色名称:</h3>
                <div>
                    <span>#(project.roleName)</span>
                </div>
            </div>
            <div class="layui-input-inline">
                <h3>预计金额:</h3>
                <div>
                    <span>#number(project.amount, ',###') 元</span>
                </div>
            </div>
            <div class="layui-input-inline">
                <h3>地址:</h3>
                <div>
                    <span>#(project.site)</span>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-inline" style="width:100%">
                <h3>简介:</h3>
                <div>
                    <span>#(project.brief)</span>
                </div>
            </div>
        </div>

        <h2 style="margin-top: 50px;">委托第三方机构评估实施/自我评估实施</h2>
        <hr class="layui-bg-orange">
        <div class="layui-input-inline">
            <h3 id="AssessmentMode">当前项目为：#(project.assessmentMode)</h3>
        </div>

        <h2 style="margin-top: 50px;">领导小组名单</h2>
        <hr class="layui-bg-blue">
        <div class="layui-form-item">
            <div class="layui-input-inline">
                <h3>组长:</h3>
                <div>
                    <span>#(leaderGroup.leader)</span>
                </div>
            </div>
            <div class="layui-input-inline">
                <h3>副组长:</h3>
                <div>
                    <span>#(leaderGroup.deputy)</span>
                </div>
            </div>
            <div class="layui-input-inline">
                <h3>组员:</h3>
                <div>
                    <span>#(leaderGroup.crew)</span>
                </div>
            </div>
        </div>

        <h2 style="margin-top: 50px;">实施小组</h2>
        <hr class="layui-bg-green">
        <div class="layui-form-pane">
            <div class="layui-form-item layui-hide" >
                <label class="layui-form-label" for="impTeam.projectID" style="width: 150px">项目名称</label>
                <div class="layui-input-inline">
                    <input type="text" id="impTeam.projectID" name="impTeam.projectID"
                           class="layui-input layui-disabled" readonly="readonly" value="#(project.name)" required/>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" for="impTeam.leaderID1" style="width: 150px">组长</label>
                <div class="layui-input-inline">
                    <label>
                        <select lay-filter="clickOption1" lay-search>
                            <option value="">请选择</option>
                            #for(List : orgStructures)
                            #if(List != null)
                            <option value="#(List.id)">#(List.name)</option>
                            #end
                            #end
                        </select>
                    </label>
                </div>
                <div class="layui-input-inline">
                    <label for="leaderID"></label><select lay-filter="clickOption11" id="leaderID" name="leaderID"
                                                          lay-search>
                    #for(List : persons)
                    <option value="#(List.id)" name="#(List.name)">#(List.name)</option>
                    #end
                </select>
                </div>
                <p class="layui-form-mid layui-word-aux" id="impTeam.leaderID1" style="margin-left: 11px"></p>
                <input class="layui-form-mid layui-word-aux layui-hide  " id="impTeam.leaderID" lay-verify="required">
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" for="impTeam.assLeaderIDs1" style="width: 150px">副组长</label>
                <div class="layui-input-inline">
                    <label>
                        <select lay-filter="clickOption2" lay-search>
                            <option value="">请选择</option>
                            #for(List : orgStructures)
                            #if(List != null)
                            <option value="#(List.id)">#(List.name)</option>
                            #end
                            #end
                        </select>
                    </label>
                </div>
                <div class="layui-input-inline">
                    <label for="assLeaderIDs"></label><select lay-filter="clickOption21" id="assLeaderIDs"
                                                              name="assLeaderIDs" lay-search>
                    #for(List : persons)
                    <option value="#(List.id)" name="#(List.name)">#(List.name)</option>
                    #end
                </select>
                </div>
                <p class="layui-form-mid layui-word-aux" id="impTeam.assLeaderIDs1"></p>
                <input class="layui-form-mid layui-word-aux layui-hide" id="impTeam.assLeaderIDs">
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" for="impTeam.expertGroupIDs1" style="width: 150px">专家成员</label>
                <div class="layui-input-inline">
                    <label>
                        <select lay-filter="clickOption3" lay-search>
                            <option value="">请选择</option>
                            #for(List : orgStructures)
                            #if(List != null)
                            <option value="#(List.id)">#(List.name)</option>
                            #end
                            #end
                        </select>
                    </label>
                </div>
                <div class="layui-input-inline">
                    <label for="expertGroupIDs"></label><select lay-filter="clickOption31" id="expertGroupIDs"
                                                                name="expertGroupIDs" lay-search>
                    #for(List : persons)
                    <option value="#(List.id)" name="#(List.name)">#(List.name)</option>
                    #end
                </select>
                </div>
                <p class="layui-form-mid layui-word-aux" id="impTeam.expertGroupIDs1"></p>
                <input class="layui-form-mid layui-word-aux layui-hide" id="impTeam.expertGroupIDs">
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" for="impTeam.invTeamIDs1" style="width: 150px">现场调查成员</label>
                <div class="layui-input-inline">
                    <label>
                        <select lay-filter="clickOption4" lay-search>
                            <option value="">请选择</option>
                            #for(List : orgStructures)
                            #if(List != null)
                            <option value="#(List.id)">#(List.name)</option>
                            #end
                            #end
                        </select>
                    </label>
                </div>
                <div class="layui-input-inline">
                    <label for="invTeamIDs"></label><select lay-filter="clickOption41" id="invTeamIDs" name="invTeamIDs"
                                                            lay-search>
                    #for(List : persons)
                    <option value="#(List.id)" name="#(List.name)">#(List.name)</option>
                    #end
                </select>
                </div>
                <p class="layui-form-mid layui-word-aux" id="impTeam.invTeamIDs1"></p>
                <input class="layui-form-mid layui-word-aux layui-hide" id="impTeam.invTeamIDs">
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label" for="impTeam.repTeamIDs1" style="width: 150px">报告编制成员</label>
                <div class="layui-input-inline">
                    <label>
                        <select lay-filter="clickOption5" lay-search>
                            <option value="">请选择</option>
                            #for(List : orgStructures)
                            #if(List != null)
                            <option value="#(List.id)">#(List.name)</option>
                            #end
                            #end
                        </select>
                    </label>
                </div>
                <div class="layui-input-inline">
                    <label for="repTeamIDs"></label><select lay-filter="clickOption51" id="repTeamIDs" name="repTeamIDs"
                                                            lay-search>
                    #for(List : persons)
                    <option value="#(List.id)" name="#(List.name)">#(List.name)</option>
                    #end
                </select>
                </div>
                <p class="layui-form-mid layui-word-aux" id="impTeam.repTeamIDs1"></p>
                <input class="layui-form-mid layui-word-aux layui-hide" id="impTeam.repTeamIDs">
            </div>
        </div>

        <h2 style="margin-top: 50px;">方案依据填写</h2>
        <hr class="layui-bg-red">
        <label for="gist"></label><textarea id="gist" name="EvaScheme.gist" style="display: none;"></textarea>

        <h2 style="margin-top: 50px;">风险评估工作拟采取的工作方式填写</h2>
        <hr class="layui-bg-orange">
        <label for="method"></label><textarea id="method" name="EvaScheme.method" style="display: none;"></textarea>

        <h2 style="margin-top: 50px;">工作要求填写</h2>
        <hr class="layui-bg-blue">
        <label for="demand"></label><textarea id="demand" name="EvaScheme.demand" style="display: none;"></textarea>

        <h2 style="margin-top: 50px;">具体措施填写</h2>
        <hr class="layui-bg-green">
        <label for="measure"></label><textarea id="measure" name="EvaScheme.measure" style="display: none;"></textarea>

        <h2 style="margin-top: 50px;">风险评估工作时间安排和进度计划表填写</h2>
        <hr class="layui-bg-black">


        <div class="layui-form-item">
            <label class="layui-form-label" for="startDate" style="width: 100px">总开始时间：</label>
            <div class="layui-input-inline">
                <input type="text" id="startDate" name="EvaScheme.startDate" autocomplete="off"
                       class="layui-input"/>
            </div>

            <label class="layui-form-label" for="endDate" style="width: 100px">总结束时间：</label>
            <div class="layui-input-inline">
                <input type="text" id="endDate" name="EvaScheme.endDate" autocomplete="off"
                       class="layui-input"/>
            </div>
        </div>

        <div class="layui-row">
            <div class="layui-btn-group ">
                <button type="button" id="addTable" class="layui-btn layui-btn-small">添加</button>
            </div>
            <table id="dateTable" lay-filter="dateTable"></table>
        </div>
        <div class="layui-progress layui-hide" style="margin-bottom:10px" lay-showpercent="true" id="upload-progress"
             lay-filter="upload-progress">
            <div class="layui-progress-bar layui-bg-green" lay-percent="0%"></div>
        </div>
        <div class="layui-row ">
            <div class="layui-btn-group">
                <button type="button" class="upFile layui-btn layui-icon" id="EvaCover">稳评方案封面</button>
                <button type="button" class="layui-btn" id="CoverSee">查看封面</button>
            </div>
        </div>

        #if(project.assessmentMode == "委评")
        <div class="layui-row" style="margin-top: 20px;">
            <div class="layui-btn-group">
                <button type="button" class="upFile layui-btn layui-icon" id="EvaEntrust">委托书</button>
                <button type="button" class="layui-btn" id="EntrustSee">查看委托书</button>
            </div>
        </div>
        #end

        <div class="layui-form-item x-center" style="margin-top: 50px;">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" data-type="content" lay-submit lay-filter="sub" id="sub">保存
                </button>
            </div>
        </div>

    </form>
</div>
#end

#define js()
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-danger layui-btn-xs layui-btn-disabled" lay-event="del" id="notDel"
       disabled=true>删除</a>
</script>

<script type="text/javascript">
    layui.use(['form', 'layer', 'element', 'table', 'laydate', 'layedit', 'table', 'upload'], function () {
        /**
         *  操作对象
         */
        var form = layui.form
            , table = layui.table
            , layer = layui.layer
            , upload = layui.upload
            , element = layui.element
            , $ = layui.jquery
            , layedit = layui.layedit
            , laydate = layui.laydate
            , temp1 = [], temp2 = [], temp3 = [], temp4 = []
            , fileFormId1 = null, fileFormId2 = null
            , fileId1 = null, fileId2 = null
            , AssString = "", ExpString = "", InvString = "", RepString = ""
            , con = 0;

        /**
         * 建立日期
         */
        laydate.render({
            elem: '#startDate'
        });
        laydate.render({
            elem: '#endDate'
        });

        /**
         * 富文本编辑器
         */
        var index1 = layedit.build('gist', {
            height: 100,
            hideTool: ['link', 'unlink', 'face', 'image', 'help']
        });

        var index2 = layedit.build('method', {
            height: 100,
            hideTool: ['link', 'unlink', 'face', 'image', 'help']
        });

        var index3 = layedit.build('demand', {
            height: 100,
            hideTool: ['link', 'unlink', 'face', 'image', 'help']
        });

        var index4 = layedit.build('measure', {
            height: 100,
            hideTool: ['link', 'unlink', 'face', 'image', 'help']
        });

        /**
         * 表格初始化
         */
        table.cache.dateTable = [];
        table.render({
            elem: '#dateTable'//指定原始表格元素选择器（推荐id选择器）
            , id: 'dateTable'
            , even: true //开启隔行背景
            , size: 'sm' //小尺寸的表格
            , height: '300'    //容器高度
            , contentType: 'application/json; charset=UTF-8'
            , cols: [[
                {type: 'numbers', unresize: 'true'}
                , {field: 'name', title: '计划名称', align: 'center', width: 200, edit: true}
                , {field: 'startDate', title: '起始时间', align: 'center', width: 200, type: 'date', edit: true}
                , {field: 'endDate', title: '结束时间', align: 'center', width: 200, type: 'date', edit: true}
                , {field: 'content', title: '工作内容', align: 'center', width: 300, edit: true}
                , {field: 'action', title: '操作', align: 'center', unresize: true, rowspan: 1, toolbar: '#barDemo'}
            ]]
            , loading: true
            , data: [{name: "", startDate: "", endDate: "", content: ""}]// 默认存在第一行
            , method: 'get'
        });

        /**
         * 表格添加事件
         */
        var not = true;
        var index = table.cache.dateTable.length;
        $('#addTable').click(function () {
            isNull();
            if (!not) {
                var tr = $('<tr data-index="' + index + '"></tr>');
                var td1 = $('<td data-field="0" align="center"><div class="layui-table-cell laytable-cell-1-0 layuitable-cell-numbers">' + (index + 1) + '</div></td>');
                var td2 = $('<td data-field="name" data-edit="true" align="center"><div class="layui-table-cell laytable-cell-1-fa"></div></td>');
                var td3 = $('<td data-field="startDate" data-edit="true" align="center" type="text"><div class="layui-table-cell dateC laytable-cell-1-fb" ></div></td>');
                var td4 = $('<td data-field="endDate" data-edit="true" align="center" type="text"><div class="layui-table-cell dateC laytable-cell-1-fc"></div></td>');
                var td5 = $('<td data-field="content" data-edit="true" align="center"><div class="layui-table-cell laytable-cell-1-fd"></div></td>');
                var td6 = $('<td data-field="action" align="center" data-off="true"><div class="layui-table-cell laytable-cell-1-action">' +
                    '<a class="layui-btn layui-btn-danger layui-btn-xs" id="del">删除</a></div></td>');
                tr.append(td1).append(td2).append(td3).append(td4).append(td5).append(td6).appendTo($('tbody').first());
                table.cache.dateTable.push({
                    "LAY_TABLE_INDEX": index,
                    "name": "",
                    "startDate": "",
                    "endDate": ""
                });
                index++;
                not = true;
                $('.dateC').each(function () {
                    laydate.render({
                        elem: this
                        , position: 'fixed'
                        , format: 'yyyy-MM-dd'
                    });
                })
            } else {
                layer.msg('表格不能为空！');
            }
        });

        /**
         * 表格删除事件
         */
        $(document).on("click", "#del", function () {
            var tr = $(this).parents("tr");
            var id = parseInt(tr.attr("data-index"));
            tr.remove();
            $.each(table.cache.dateTable, function (index, value) {
                if (value.LAY_TABLE_INDEX === id) {
                    value.LAY_TABLE_INDEX = -1;
                }
            });
            not = false;
        });

        /**
         * 一级下拉框点击事件:
         * 调用getJson函数以获取二级下拉框将要显示的数据
         */
        form.on('select(clickOption1)', function (data) {
            getJson("#leaderID", data);
        });
        form.on('select(clickOption2)', function (data) {
            getJson("#assLeaderIDs", data);
        });
        form.on('select(clickOption3)', function (data) {
            getJson("#expertGroupIDs", data);
        });
        form.on('select(clickOption4)', function (data) {
            getJson("#invTeamIDs", data);
        });
        form.on('select(clickOption5)', function (data) {
            getJson("#repTeamIDs", data);
        });

        /**
         * 二级联动的数据获取
         */
        function getJson(id, data) {
            var flag = false;
            if (id === "#expertGroupIDs") {
                flag = true;
            }
            $.getJSON(
                "#(ctxPath)/app/projectUndertake/persons?orgStructureId=" + data.value + "&flag=" + flag,
                function (data) {
                    var optionString = "";
                    var string = "";
                    $.each(data.persons, function (i, item) {
                        optionString += '<option value= "' + item.id + '">' + item.name + '</option>';
                    });
                    $(id).html('<option value=""></option>' + optionString);
                    form.render('select'); //这个很重要
                }
            );
        }

        /**
         * 二级下拉框的点击事件:
         * 调用judge函数使得人员选择不能重复
         * 并且将隐藏的h结点赋值value以方便数据库调用
         */
        form.on('select(clickOption11)', function (data) {
            $("#impTeam\\.leaderID1").text(data.elem[data.elem.selectedIndex].text);
            $("#impTeam\\.leaderID").val(data.value);
        });
        form.on('select(clickOption21)', function (data) {
            judge("impTeam.assLeaderIDs", "#impTeam\\.assLeaderIDs", "#impTeam\\.assLeaderIDs1", data, temp1)
        });
        form.on('select(clickOption31)', function (data) {
            judge("impTeam.expertGroupIDs", "#impTeam\\.expertGroupIDs", "#impTeam\\.expertGroupIDs1", data, temp2)
        });
        form.on('select(clickOption41)', function (data) {
            judge("impTeam.invTeamIDs", "#impTeam\\.invTeamIDs", "#impTeam\\.invTeamIDs1", data, temp3)
        });
        form.on('select(clickOption51)', function (data) {
            judge("impTeam.repTeamIDs", "#impTeam\\.repTeamIDs", "#impTeam\\.repTeamIDs1", data, temp4)
        });

        /**
         * 禁止重复选择
         * 显示name，返回value
         */
        function judge(id, id1, id2, data, temp) {
            var count = temp.length;
            con++;
            for (var i = 0; i < temp.length; i++) {
                if (temp[i] === data.value) {
                    count--;
                }
            }
            if (count === temp.length) {
                temp.length++;
                temp[temp.length - 1] = data.value;
                $("<p class=\"layui-form-mid layui-word-aux \"  title=" + con + ">" + data.elem[data.elem.selectedIndex].text + "</p>").insertAfter($(id2));
                $("<input class=\"layui-form-mid layui-word-aux layui-hide\" title=" + con + " name=" + id + " value=" + data.value + " lay-verify=\"required\">").insertAfter($(id1));
            }
        }

        /**
         * 实施小组人员删除事件,因为是动态生成的标签要用live方法
         * 才发现jqury1.9以上版本被抛弃了,换成on方法,
         */
        $(document).on("click", "p", function () {
            var id = $(this).attr("id");
            var title = $(this).attr("title");
            if (id === "impTeam.leaderID1") {
                $(this).text("");
                $("#impTeam\\.leaderID").val("");
            } else {
                $(this).remove();
                $("input[name='impTeam.assLeaderIDs']").each(function () {
                    if (title === $(this).attr("title")) {
                        $(this).remove();
                        ArrRemove(temp1, $(this).val());
                    }
                });
                $("input[name='impTeam.expertGroupIDs']").each(function () {
                    if (title === $(this).attr("title")) {
                        $(this).remove();
                        ArrRemove(temp2, $(this).val());
                    }
                });
                $("input[name='impTeam.invTeamIDs']").each(function () {
                    if (title === $(this).attr("title")) {
                        $(this).remove();
                        ArrRemove(temp3, $(this).val());
                    }
                });
                $("input[name='impTeam.repTeamIDs']").each(function () {
                    if (title === $(this).attr("title")) {
                        $(this).remove();
                        ArrRemove(temp4, $(this).val());
                    }
                });
            }
        });

        /**
         * 删除之后还要对去重留下的标识变量temp进行线性表的移动操作
         */
        function ArrRemove(temp, data) {
            for (var i = 0; i < temp.length; i++) {
                if (temp[i] === data) {
                    for (var j = i; j < temp.length - 1; j++) {
                        temp[j] = temp[j + 1];
                    }
                    temp.length--;
                }
            }
        }

        /**
         *  触摸显示删除的图标
         */
        $(document).on("mouseover", "p", function () {
            this.style.cursor = "url('/static/img/delete-2.ico'),auto";
        });

        /**
         * 判表格是否空逻辑
         */
        function isNull() {
            $.each(table.cache.dateTable, function notNull(index, value) {
                if (value.LAY_TABLE_INDEX >= 0) {
                    if (value.name != null) {
                        not = (value.content == null || value.content == "")
                    } else
                        not = true;
                }
            });
            $('.dateC').each(function () {
                if ($(this).text() === '' || $(this).text() === ' ')
                    not = true;
            });
        }

        /**
         * 判总日期是否不正确
         */
        function dateIsCorrect() {
            var startDate = new Date($('#startDate').val());
            var endDate = new Date($('#endDate').val());
            var startDate1;
            var endDate1;
            var temp = 2;
            var date = true;
            $('.dateC').each(function () {
                if (temp % 2 === 0) {
                    startDate1 = new Date($(this).text());
                    if ($(this).text() === '' || $(this).text() === ' ')
                        date = false;
                    if (startDate > startDate1)
                        date = false;
                    temp++;
                } else {
                    endDate1 = new Date($(this).text());
                    if ($(this).text() === '' || $(this).text() === ' ')
                        date = false;
                    if (endDate < endDate1)
                        date = false;
                    temp++;
                    if (startDate1 > endDate1)
                        date = false;
                }
            });
            if (startDate > endDate)
                date = false;

            return date;
        }

        /**
         * 判总表格填写是否为空
         */
        function tableNull() {
            var dte = false;
            $.each(table.cache.dateTable, function notNull(index, value) {
                if (value.LAY_TABLE_INDEX >= 0) {
                    if (value.name != null) {
                        dte = value.content != null;
                    } else
                        dte = false;
                }
            });
            $('.dateC').each(function () {
                if ($(this).text() === '' || $(this).text() === ' ')
                    dte = false;
            });
            return dte
        }

        //创建监听函数
        var xhrOnProgress = function (fun) {
            xhrOnProgress.onprogress = fun; //绑定监听
            //使用闭包实现监听绑
            return function () {
                //通过$.ajaxSettings.xhr();获得XMLHttpRequest对象
                var xhr = $.ajaxSettings.xhr();
                //判断监听函数是否为函数
                if (typeof xhrOnProgress.onprogress !== 'function')
                    return xhr;
                //如果有监听函数并且xhr对象支持绑定时就把监听函数绑定上去
                if (xhrOnProgress.onprogress && xhr.upload) {
                    xhr.upload.onprogress = xhrOnProgress.onprogress;
                }
                return xhr;
            }
        }

        /**
         * 文件上传
         */
        upload.render({
            elem: '.upFile'
            , url: '#(ctxPath)/util/uploadFile'
            , accept: 'file'
            , exts: 'pdf|png|jpeg|jpg'
            , xhr: xhrOnProgress
            , progress: function (value) {//上传进度回调 value进度值
                element.progress('upload-progress', value + '%')//设置页面进度条
            }
            , data: {
                description: $('#modelName').text()
            }, before: function (res) {
                $('#upload-progress').removeClass('layui-hide');
            }, done: function (res) {
                <!--$('.loading-bg').remove();-->
                $('#upload-progress').addClass('layui-hide');
                var ele = $(this)[0].item;
                if (res.code == 0) {
                    var flag;
                    util.sendAjax({
                        type: 'GET',
                        url: '#(ctxPath)/app/projectUndertake/upFile',
                        async: false,
                        data: {
                            fileId: res.data.fileId,
                            fieldName: ele.text()
                        },
                        loadFlag: true,
                        success: function (data) {
                            if (data.code == 0) {
                                if (ele.attr('id') === "EvaEntrust") {
                                    fileFormId2 = data.data.fileFormId;
                                } else {
                                    fileFormId1 = data.data.fileFormId;
                                }
                                flag = true;
                            }
                        }
                    });
                    if (flag) {
                        $(ele.text("已上传（更改）"));
                    }
                    if (ele.attr('id') === "EvaEntrust") {
                        fileId2 = res.data.fileId;
                    } else {
                        fileId1 = res.data.fileId;
                    }
                } else if (res.code == 1) {
                    return false;
                }
            }, error: function (index, upload) {
                $('#upload-progress').addClass('layui-hide');
                layer.msg("文件上传错误！请重新尝试！");
            }
        });

        /**
         * 文件查看
         */
        $("#CoverSee").click(function () {
            if (fileId1 === null || fileId1 === "") {
                layer.msg("您还没有上传稳评封面哦")
            } else {
                pop_show('查看封面文件', '#(ctxPath)/util/pdfView?fileID=' + fileId1, '', '', function () {
                });
            }
        });

        $("#EntrustSee").click(function () {
            if (fileId2 === null || fileId2 === "") {
                layer.msg("您还没有上传委托书哦")
            } else {
                pop_show('查看委托书文件', '#(ctxPath)/util/pdfView?fileID=' + fileId2, '', '', function () {
                });
            }
        });

        /**
         * 数据打包
         */
        function dataString() {
            var data = {};
            //两个文件
            data.fileFormId1 = fileFormId1;
            data.fileFormId2 = fileFormId2;

            //四个富文本框
            data['EvaScheme.gist'] = layedit.getContent(index1);
            data['EvaScheme.method'] = layedit.getContent(index2);
            data['EvaScheme.demand'] = layedit.getContent(index3);
            data['EvaScheme.measure'] = layedit.getContent(index4);

            //计划表的名称和内容
            data['ScheduledPlan.name'] = [];
            data['ScheduledPlan.content'] = [];
            $.each(table.cache.dateTable, function (index, value) {
                if (value.LAY_TABLE_INDEX >= 0) {
                    data['ScheduledPlan.name'].push(value.name);
                    data['ScheduledPlan.content'].push(value.content);
                }
            });
            data['ScheduledPlan.name'] = JSON.stringify(data['ScheduledPlan.name']);
            data['ScheduledPlan.content'] = JSON.stringify(data['ScheduledPlan.content']);

            //计划表的日期
            var temp = 2;
            data['ScheduledPlan.startDate'] = [];
            data['ScheduledPlan.endDate'] = [];
            $('.dateC').each(function () {
                if (temp % 2 === 0) {
                    data['ScheduledPlan.startDate'].push($(this).text());
                } else {
                    data['ScheduledPlan.endDate'].push($(this).text());
                }
                temp++;
            });
            data['ScheduledPlan.startDate'] = JSON.stringify(data['ScheduledPlan.startDate']);
            data['ScheduledPlan.endDate'] = JSON.stringify(data['ScheduledPlan.endDate']);

            //实施小组
            function ArrToString(temp, string) {
                for (var i = 0; i < temp.length; i++) {
                    string += temp[i] + ",";
                }
                return string;
            }

            console.log(temp1 + "," + temp2 + "," + temp3 + "," + temp4);
            data['impTeam.leaderID'] = $("#impTeam\\.leaderID").val();
            data['impTeam.assLeaderIDs'] = ArrToString(temp1, AssString);
            data['impTeam.expertGroupIDs'] = ArrToString(temp2, ExpString);
            data['impTeam.invTeamIDs'] = ArrToString(temp3, InvString);
            data['impTeam.repTeamIDs'] = ArrToString(temp4, RepString);

            //实施小组名称
            data[$("#impTeamName").attr('name')] = $("#impTeamName").val();

            //计划总时间
            data[$("#startDate").attr('name')] = $("#startDate").val();
            data[$("#endDate").attr('name')] = $("#endDate").val();

            //projectID和status
            data.id = '#(project.id)';
            data.status = '#(status)';
            console.log(data);
            return data;
        }

        /**
         * 提交
         */
        form.on('submit(sub)', function () {
            if (dateIsCorrect()) {
                //if ($("#impTeamName").val() != null && $("#impTeamName").val() !== '') {
                if (tableNull()) {
                    if (layedit.getText(index1) != null && layedit.getText(index1) !== "" && layedit.getText(index2) != null && layedit.getText(index2) !== "" && layedit.getText(index3) != null && layedit.getText(index3) !== "" && layedit.getText(index4) != null && layedit.getText(index4) !== "") {
                        var ajaxTimeoutTest = $.ajax({
                            type: 'POST',
                            timeout: 3000,
                            url: '#(ctxPath)/app/projectUndertake/ImpTeam',
                            data: dataString(),
                            loadFlag: true,
                            success: function (data) { //请求成功的回调函数
                                window.parent.location.reload();
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                                layer.msg("操作成功");
                            },
                            error: function (data) { //请求失败的回调函数
                                string = "?";
                                layer.msg("操作失败");
                            },
                            complete: function (XMLHttpRequest, status) { //请求完成后最终执行参数
                                if (status === 'timeout') {//超时,status还有success,error等值的情况
                                    ajaxTimeoutTest.abort();
                                    string = "?";
                                    layer.msg("请求超时");
                                }
                            }
                        });
                    } else {
                        layer.msg("必填项不能为空！");
                        return false;
                    }
                } else {
                    layer.msg("至少有一条计划！且计划不能为空");
                }
                //}
            } else {
                layer.msg("计划日期填写错误！");
            }
            return false;
        });
        $("tr[data-index=0]").children("td[data-field*=Date]").children("div").addClass("dateC");
        $("tr[data-index=0]").children("td[data-field*=Date]").children("div").each(function () {
            laydate.render({
                elem: this
                , position: 'fixed'
                , format: 'yyyy-MM-dd'
            });
        })
    });

</script>
#end